<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"
	language="java"%>
<%@ include file="/jsp/platform/include/include.jsp"%>
<%@page import="java.util.UUID"%>
<%
String uuid = UUID.randomUUID().toString();
String editFlag=(String)request.getAttribute("editFlag");
String methodName="merchantInfoApplyTaskAdd";
if(editFlag!=null){
	methodName="merchantInfoApplyTaskEdit";
}
%>
<html>
<head>
<TITLE><c:out value="${_LOGONUSER_.MANAGETITILE}" />
</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<%@ include file="/jsp/platform/include/header.jsp"%>
	<script type="text/javascript">
		$(document).ready(function() {
			var taskId = "<c:out value='${taskId}'/>";
			//alert(taskId);
			if (taskId != null && taskId != "") {
				$.messager.alert("提示信息", "商户申请成功!");
			}			
			$("#depositBank").val("<c:out value='${model.settleCardInfoModel.depositBank}'/>");
			//先隐藏所有证件信息
		      $("div[name='fileDiv']").hide(); 	
			// //新建商户产品类型默认选POS终端，商户类型默认商户edit by wenjw 2015.7.11
		      $("#file1Div").show();
        	  $("#file2Div").show();
        	  $("#file7Div").show();
        	  $("#file9Div").show();
        	  $("#file10Div").show();
		});
		
		
	</script>
</HEAD>
<BODY>
	<DIV class="all">
		<%@ include file="/jsp/platform/include/head.jsp"%>
		<%@ include file="/jsp/platform/include/menu.jsp"%>
		<DIV class="mains">
			<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
				<TBODY>
					<TR valign="top">
						<%@ include file="/jsp/platform/include/mainLeft.jsp"%>
						<TD>
							<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
								<TBODY>
									<TR>
										<TD>
											<TABLE width="180" border="0" cellspacing="0" cellpadding="0">
												<TBODY>
													<TR>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_l.jpg">
														</TD>
														<TD align="center"
															background="<%=request.getContextPath()%>/images/pages_bg.jpg">
															<SPAN class="f_tit1">商户信息录入</SPAN>
														</TD>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_r.jpg">
														</TD>
													</TR>
												</TBODY>
											</TABLE>
										</TD>
									</TR>
								</TBODY>
								<TR>
									<TD>
										<div class="pages_con">
											<!--创建页面-->
											<TR>
<TD>
	<div class="pages_con">
		<form method="post"
			action="<%=request.getContextPath()%>/manage/merchantInfo/<%=methodName%>"
				id="merchantInfoForm" name="merchantInfoForm"
				enctype="multipart/form-data"
			>
			<div class="pages_con_20">
				<TABLE class="table" style="font-size:12px;">
					<THEAD style="color:#333">
						<TBODY>
							<TR>
								<TD><span class="tdbold">基本信息</span></td>
							</tr>
							<TR>
								<TD>
									<!-- //开户行 -->
							        <common:getDicListByKey key="2100" var="depositBankList"/>
							        <common:getDicListByKey key="2140" var="productTypeList"/>
							        <common:getDicListByKey key="2150" var="merchantTypeList"/>
									<DIV class="transaction_external">
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">所在省份：</SPAN>
											<INPUT name="merchantInfoModel.merchantProvince"
												value="${model.merchantInfoModel.merchantProvince}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="merchantProvince" type="text"> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">所在城市：</SPAN>
												<INPUT name="merchantInfoModel.merchantCity"
												 value="${model.merchantInfoModel.merchantCity}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="merchantCity" type="text">
										</DIV>

										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">商户名称：</SPAN>
											<INPUT name="merchantInfoModel.merchantName"
											 value="${model.merchantInfoModel.merchantName}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="merchantName" type="text">  <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">经营地址：</SPAN>
												<INPUT name="merchantInfoModel.merchantAddr"
												 value="${model.merchantInfoModel.merchantAddr}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="merchantAddr" type="text">
										</DIV>

										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">法人姓名：</SPAN>
											<INPUT name="merchantInfoModel.legalName"
											 value="${model.merchantInfoModel.legalName}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="legalName" type="text"> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">法人证件号：</SPAN>
												<INPUT name="merchantInfoModel.legalIdentityno"
												 value="${model.merchantInfoModel.legalIdentityno}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="legalIdentityno" type="text">
										</DIV>
										<DIV class="clearfix"></DIV>
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">经营范围：</SPAN>
											<INPUT name="merchantInfoModel.bussinessScope"
											 value="${model.merchantInfoModel.bussinessScope}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="bussinessScope" type="text">  <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">联系电话：</SPAN>
												<INPUT name="merchantInfoModel.telephone"
												 value="${model.merchantInfoModel.telephone}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="telephone" type="text">
										</DIV>
										<DIV class="clearfix"></DIV>
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">产品类型：</SPAN>
												<SPAN class="label dl_w"
																style="padding-left:0px;text-align:center;height:30px;width:230px;">
											<select id="productType" name="merchantInfoModel.productType">
														<option value="">请选择</option>
														<c:forEach var="list" items="${productTypeList}">
														<option value="${list.dirValue}"><c:out value='${list.dirCaption}'/></option>
														</c:forEach>
													</select> </SPAN><span
												class="reds f_l">*</span> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">商户类型：</SPAN>
												<SPAN class="label dl_w"
																style="padding-left:0px;text-align:center;height:30px;width:230px;">
												<select id="merchantType" name="merchantInfoModel.merchantType">
														<option value="">请选择</option>
														<c:forEach var="list" items="${merchantTypeList}">
														<option value="${list.dirValue}"><c:out value='${list.dirCaption}'/></option>
														</c:forEach>
													</select></SPAN> <span
													class="reds f_l">*</span>
										</DIV>
										<DIV class="clearfix"></DIV>
									</DIV>
								</TD>
							</TR>
							<TR>
								<TD><span class="tdbold">账户信息</span></td>
							</tr>
							<TR>
								<TD>
									<DIV class="transaction_external">
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">系统账号：</SPAN>
											<INPUT name="merchantInfoModel.sysAccount"
											 value="${model.merchantInfoModel.sysAccount}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="sysAccount" type="text"> <span
												class="reds f_l">*</span> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">登陆密码：</SPAN>
												<INPUT name="merchantInfoModel.sysPassword"
												 value="${model.merchantInfoModel.sysPassword}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="sysPassword" type="password"> <span
													class="reds f_l">*</span>
										</DIV>
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">交易密码：</SPAN>
											<INPUT name="merchantInfoModel.tradePassword"
											 value="${model.merchantInfoModel.tradePassword}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="tradePassword" type="password"> <span
												class="reds f_l">*</span>
										</DIV>
									</DIV>
									<DIV class="clearfix"></DIV>
									</DIV>
								</TD>
							</TR>
							<TR>
								<TD><span class="tdbold">结算信息</span></td>
							</tr>
							<TR>
								<TD>
									<DIV class="transaction_external">
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">开户行：</SPAN> 
												<SPAN class="label dl_w"
																style="padding-left:0px;text-align:center;height:30px;width:230px;">
													<select id="depositBank" name="settleCardInfoModel.depositBank">
														<option value="">请选择开户行</option>
														<c:forEach var="list" items="${depositBankList}">
														<option value="${list.dirValue}"><c:out value='${list.dirCaption}'/></option>
														</c:forEach>
													</select>
												</SPAN>
												<span
												class="reds f_l">*</span> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">开户行支行：</SPAN>
												<INPUT name="settleCardInfoModel.depositBankbranch"
												 value="${model.settleCardInfoModel.depositBankbranch}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="depositBankbranch" type="text">
											    <span
													class="reds f_l">*</span>
										</DIV>
										<DIV class="clearfix"></DIV>
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">开户名：</SPAN> <INPUT
												name="settleCardInfoModel.bankUsrname"
												 value="${model.settleCardInfoModel.bankUsrname}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="bankUsrname" type="text"> <span
												class="reds f_l">*</span> <SPAN
												class="label cz_label "
												style="width:120px;text-align:right;">开户账号：</SPAN>
												<INPUT name="settleCardInfoModel.bankAccount"
												 value="${model.settleCardInfoModel.bankAccount}"
												class="txtbox_cz txtbox_cz_color input_change"
												id="bankAccount" type="text"> <span
													class="reds f_l">*</span>
										</DIV>
										<DIV class="clearfix"></DIV>
										<DIV class="clearfix">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">T+O额度：</SPAN>
											<INPUT name="merchantInfoModel.t0Limit"
												class="txtbox_cz txtbox_cz_color input_change"
												 value="${model.merchantInfoModel.t0Limit}"
												id="t0Limit" type="text"> <span
												class="reds f_l">万元</span>
										</DIV>
										<DIV class="clearfix"></DIV>
									</DIV>
								</TD>
							</TR>
							<TR>
								<TD><span class="tdbold">证件信息</span></td>
							</tr>
							<TR>
								<TD>
									<DIV class="transaction_external">

										<DIV class="clearfix"  id="file1Div" name="fileDiv">
											<SPAN class="label cz_label "
												style="width:120px;text-align:right;">身份证和信用卡：</SPAN>
											<input id="file1" type="file" name="file"
												value="请选择文件"
												style="height:31px;margin:1px 0 0 0;;width:280px;" />
											<span class="reds">*</span>
										</DIV>
										<DIV class="clearfix"></DIV>
										<DIV class="clearfix"  id="file9Div" name="fileDiv">
											<SPAN class="label cz_label"
												style="width:120px;text-align:right;">手持身份证半身照：</SPAN>
											<input id="file9" type="file" name="file"
												value="请选择文件"
												style="height:31px;margin:1px 0 0 0;;width:280px;" />
											<span class="reds">*</span>	
										</DIV>
											<DIV class="clearfix">
											<input type="hidden" name="todoTaskModel.taskId" value="${model.taskId}">
											<input type="hidden" name="todoTaskModel.taskType" value="1">
											<input type="hidden" name="todoTaskModel.taskOperatorType" value="2">
											<input type="hidden" name="todoTaskModel.applyType" value='<c:out value="${_LOGONUSER_.operatorInfoModel.operatorType}"/>'>
											<input type="hidden" name="todoTaskModel.applyOperator" value='<c:out value="${_LOGONUSER_.operatorInfoModel.loginName}"/>'>
											<input type="hidden" name="todoTaskModel.approveStatus" value="0">
											</DIV>
											<DIV class="note">
												<SPAN class="label cz_label">&nbsp;</SPAN> <A
													class="btn confirm" href="javascript:void(0);"
													onclick="submitForm()" style="margin-left:113px;">确定</A>
											</DIV>
										</DIV>
								</TD>
							</TR>
						</TBODY>
				</TABLE>
			</div>
		</form>
	</div></TD>
</TR>
											<!--结束-->
							</TABLE>
						</TD>
					</TR>
				</TBODY>
			</TABLE>
		</DIV>
		<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
			<TBODY>
				<TR>
					<TD width="5" bgcolor="#f1fcfe"><IMG width="5" height="5"
						src="<%=request.getContextPath()%>/images/footer_l.jpg">
					</TD>
					<TD bgcolor="#f1fcfe">&nbsp; <br /></TD>
					<TD width="5" bgcolor="#f1fcfe"><IMG width="5" height="5"
						src="<%=request.getContextPath()%>/images/footer_r.jpg">
					</TD>
				</TR>
			</TBODY>
		</TABLE>
		<%@ include file="/jsp/platform/include/foot.jsp"%>
		<script type="text/javascript">
			function del(obj) {
				$(obj).parent().remove();
			}
			function showZdDiv(id) {
				var a = document.getElementById(id).style.display;
				if (a == "none") {
					document.getElementById(id).style.display = "";
				} else {
					document.getElementById(id).style.display = "none";
				}
			}
			function resetForm() {
				document.passwordForm.reset();
			}
			function submitForm() {
			    //检验所有字段  identityNo
				var checkStr =
//								"need|merchantProvince|所在省份|"+ $("#merchantProvince").val()+";"
//				                +"need|merchantCity|所在城市|"+ $("#merchantCity").val() + ";"
//				                +"need|merchantName|商户名称|"+ $("#merchantName").val() + ";"
//				                //+"need|mobilephone|手机|"+ $("#mobilephone").val() + ";"
//				                +"need|merchantAddr|经营地址|"+ $("#merchantAddr").val() + ";"
//				                +"need|legalName|法人姓名|"+ $("#legalName").val() + ";"
//				                +"need|legalIdentityno|法人证件号|"+ $("#legalIdentityno").val() + ";"
//				                +"identityNo|legalIdentityno|法人证件号|"+ $("#legalIdentityno").val() + ";"
//							    +"need|bussinessScope|经营范围|" + $("#bussinessScope").val() + ";"
//								+"need|telephone|联系电话|" + $("#telephone").val() + ";"
								//检验联系电话    联系电话按手机号校验
//				                +"mobile|telephone|联系电话|"+ $("#telephone").val() + ";"
								+"need|productType|产品类型|" + $("#productType").val() + ";"
								+"need|merchantType|商户类型|" + $("#merchantType").val() + ";"
								+"need|sysAccount|系统账号|" + $("#sysAccount").val() + ";"
								+"sysAccount|sysAccount|系统账号|" + $("#sysAccount").val() + ";"
								+"need|sysPassword|密码|" + $("#sysPassword").val() + ";"
								+"need|tradePassword|交易密码|" + $("#tradePassword").val() + ";"
								+"need|depositBank|开户行|" + $("#depositBank").val() + ";"
								+"need|depositBankbranch|开户支行|"+ $("#depositBankbranch").val() + ";"
								+"need|bankUsrname|开户名|" + $("#bankUsrname").val() + ";"
								+"need|bankAccount|开户账号|" + $("#bankAccount").val() + ";"
								+"need|t0Limit|T+O额度|" + $("#t0Limit").val() + ";"
				                //bankAccount
				                +"account|bankAccount|开户账号|"+ $("#bankAccount").val() + ";"
				                //检验double
				                +"double|t0Limit|T+O额度|"+ $("#t0Limit").val() + ";"
				                ;
				var merchantType = $("#merchantType").val();
				if(merchantType=="1"||merchantType=="2"){
				   checkStr = checkStr
				              //检验文件类型
				                //检验证件信息
				                +"need|file1|身份证和信用卡|" + $("#file1").val() + ";"
								//+"need|file2|法人身份证反面|" + $("#file2").val() + ";"
								//+"need|file7|结算银行卡正面|"+ $("#file7").val() + ";"
								+"need|file9|手持身份证半身照|"+ $("#file9").val() + ";"
//								+"need|file10|结算银行卡|"+ $("#file10").val() + ";"
								+"fileType|file1|身份证和信用卡|"+ $("#file1").val() + "|jpg,JPG,png,PNG,gif,GIF;"
//				                +"fileType|file2|法人身份证反面|"+ $("#file2").val() + "|jpg,JPG,png,PNG,gif,GIF;"
//				                +"fileType|file7|结算银行卡正面|"+ $("#file7").val() + "|jpg,JPG,png,PNG,gif,GIF;"
//				                +"fileType|file9|手持身份证半身照|"+ $("#file9").val() + "|jpg,JPG,png,PNG,gif,GIF;"
//				                +"fileType|file10|结算银行卡|"+ $("#file10").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                ;
				}else if(merchantType=="3"){
				  checkStr = checkStr
				                //检验证件信息
				                +"need|file1|身份证和信用卡|" + $("#file1").val() + ";"
								+"need|file2|法人身份证反面|" + $("#file2").val() + ";"
								+"need|file3|营业执照|" + $("#file3").val() + ";"
								+"need|file7|结算银行卡正面|"+ $("#file7").val() + ";"
								+"need|file8|营业场所照片|"+ $("#file8").val() + ";"
				              //检验文件类型
								+"fileType|file1|身份证和信用卡|"+ $("#file1").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file2|法人身份证反面|"+ $("#file2").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file3|营业执照|"+ $("#file3").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file4|组织机构代码证|"+ $("#file4").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file5|税务登记证|"+ $("#file5").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file6|开户银行许可证|"+ $("#file6").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file7|结算银行卡正面|"+ $("#file7").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                +"fileType|file8|营业场所照片|"+ $("#file8").val() + "|jpg,JPG,png,PNG,gif,GIF;"
				                ;
				}                
				//检验所有规则
				if (!checkAll(checkStr)) {
					return false;
				}
				
				$('#merchantInfoForm').submit();
				ajaxLoading();

			} 
			 $("#sysAccount").change(function(){
		        	var sysAccount = $("#sysAccount").val();
			        var url = '<%=request.getContextPath()%>/manage/merchantInfo/isExistsSysAccount';
			        $.post(url,
                 {
                     'sysAccount' : sysAccount
                 },
                 function(data) {
                 data = eval("("+data+")")
                     if (data.success) {
                      	
                     } else {
                         $.messager.alert("提示信息", "系统账号已经存在");
                         $("#sysAccount").val("");
                     }
                 });
		        });
		        $("#merchantType").change(function(){
		        	var merchantType = $("#merchantType").val();
		        	$("div[name='fileDiv']").hide();
		        	if(merchantType == "1"||merchantType=="2"){
		        	  $("#file1Div").show();
		        	  $("#file9Div").show();
		        	}else if(merchantType == "3"){
		        		$("#file1Div").show();
			        	  $("#file2Div").show();
			        	  $("#file3Div").show();
			        	  $("#file4Div").show();
			        	  $("#file5Div").show();
			        	  $("#file6Div").show();
			        	  $("#file7Div").show();
			        	  $("#file8Div").show();
		        	}
		        });
					 //新建商户产品类型默认选POS终端，商户类型默认商户edit by wenjw 2015.7.11
				    $("#productType").val("1");
				    $("#merchantType").val("1");
		</script>
</BODY>
</HTML>
